package com.example.day7.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.day7.R;
import com.example.day7.bean.BijiBean;

import java.util.List;

public class BiAdapter extends RecyclerView.Adapter<BiAdapter.ViewHolder> {
    private Context context;
    private List<BijiBean> data;

    public BiAdapter(Context context, List<BijiBean> data) {
        this.context = context;
        this.data = data;
    }

    @NonNull
    @Override
    public BiAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.biitem, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull BiAdapter.ViewHolder holder, int position) {
        BijiBean bijiBean = data.get(position);
        holder.tilte.setText(bijiBean.getTilte());
        holder.name.setText(bijiBean.getName());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        TextView tilte;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            name=itemView.findViewById(R.id.name);
            tilte=itemView.findViewById(R.id.title);
        }
    }
}
